<?php
// 初始化变量及引入初始文件
$dbPathPart		= '';
$webPathPart	= '';
$jsPathPart		= '';

require(dirname(__FILE__) .'/check.php');
require(OT_ROOT .'inc/classTemplate.php');
//require(OT_ROOT .'inc/classTplIndex.php');


$areaName	= 'IDC产品';
$title = $areaName;

$tpl = new Template;
// $tpl->pointStr	= '&ensp;&gt;&ensp;'. $areaName;

$dataID = OT::GetInt('dataID');
$isHtml = OT::GetInt('isHtml');

$webMenu = $webContent = '';
if ($dataID <= 0){
	$webContent = '<center class="font1_1 padd8" style="padding:20px;">指定ID错误</center>';
}else{
	$typeexe = $DB->query('select IPT_ID,IPT_theme,IPT_fieldNum,IPT_fieldStr,IPT_level,IPT_fatID,IPT_priceType,IPT_tixing,IPT_htmlName from '. OT_dbPref .'idcProType where IPT_ID='. $dataID);
	if (! $row = $typeexe->fetch()){
		$webContent = '<center class="font1_1 padd8" style="padding:20px;">指定ID错误！</center>';
	}else{
		$areaName = $row['IPT_theme'];
		$title = $areaName;

		if ($row['IPT_level'] == 2){
			// 菜单
			$webMenu = AppIdcPro::ListMenuBox($row['IPT_fatID'], $dataID, $isHtml);

			// 读取一级栏目信息
			$fatRow = $DB->GetRow('select IPT_theme,IPT_tixing from '. OT_dbPref .'idcProType where IPT_ID='. $row['IPT_fatID']);

			$title = $areaName .'_'. $fatRow['IPT_theme'];

			// 读取商品信息
			switch ($row['IPT_priceType']){
				case 'serv1':
					$webContent .= AppIdcPro::ListServ1Box($row,$fatRow);
					break;
			
				case 'vps1':
					$webContent .= AppIdcPro::ListVps1Box($row,$fatRow);
					break;
			
				default :
					$webContent .= AppIdcPro::ListHost1Box($row,$fatRow);
					break;
			}
		}else{
			// 菜单
			$webMenu = AppIdcPro::ListMenuBox($row['IPT_ID'], 0, $isHtml);

			$webContent = '<center class="font1_1 padd8" style="padding:20px;">页面错误，请选择上面子菜单</center>';
		}
	}
	unset($typeexe);
}

// 初始化公共变量
$tpl->webTypeName	= 'idcPro';
$tpl->areaName		= $areaName;
$tpl->webTitle		= str_replace(array('{%标题附加%}','{%标题%}'),array('',$title),$systemArr['SYS_titleWeb']);
$tpl->webTitleAddi	= '';
$tpl->webKey		= $systemArr['SYS_webKey'];
$tpl->webDesc		= $systemArr['SYS_webDesc'];

$tpl->Add('areaName',		$tpl->areaName);	// 标题
$tpl->Add('webMenu',		$webMenu);			// 菜单
$tpl->Add('webContent',		$webContent);		// 内容


// 解析页面
$tpl->WebTop();
$tpl->WebBottom();
$tpl->WebSubRight();

$retStr = $tpl->GetShow('idcPro.html');

if ($isHtml == 1){
	if (strlen($row['IPT_htmlName'])>0){
		if (! File::Write(OT_ROOT . $row['IPT_htmlName'], $retStr . PHP_EOL .'<!-- Html For '. TimeDate::Get() .' -->')){
			MakeDiy::HtmlErr('<div style="font-size:14px;color:red;">PC版生成失败!</div>');
		}else{
			if ($row['IPT_ID'] > 0){ $DB->UpdateParam('idcProType', array('IPT_htmlTime'=>TimeDate::Get()), 'IPT_ID='. $row['IPT_ID']); }
			MakeDiy::HtmlErr('<div style="font-size:14px;color:green;">PC版生成成功!</div>');
		}

	}
}else{
	echo($retStr);
}
?>